<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/admin/include/init_admin.jsp" %>
<%@ page import="com.joinhawaii.admin.sales.*" %>
<%

	HashList code001	= CommonUtil.getCodeList("001", "선택");		//섬
	HashList code005	= CommonUtil.getCodeList("005", "선택");	//항공사
	HashList code008	= CommonUtil.getCodeList("008", "선택");		//차종
	HashList code013	= CommonUtil.getCodeList("013", "선택");		//포함여부
	HashList code100	= CommonUtil.getCodeList("100");		//여행구분
	HashList code101	= CommonUtil.getCodeList("101");		//여행종류
	HashList code102	= CommonUtil.getCodeList("102");		//성별
	HashList code106	= CommonUtil.getCodeList("106");		//렌터카회사
	HashList code110	= CommonUtil.getCodeList("110", "선택");		//픽업/반납
	//HashList code114	= CommonUtil.getCodeList("114");		//블럭
	//HashList code115	= CommonUtil.getCodeList("115");		//직항경유
	//HashList code116	= CommonUtil.getCodeList("116");		//발권사
	HashList codeHotel	= CommonUtil.getCodeList("hotel", "선택");	//호텔
	HashList codeEnjoy	= CommonUtil.getCodeList("enjoy", "선택");	//선택관광
	HashList codeCar	= CommonUtil.getCodeList("car", "선택");	//렌터카

	String job_type		= "U";
	String est_no		= StringUtil.nvl(request.getParameter("est_no"));
	String req_id		= StringUtil.nvl(request.getParameter("req_id"));
	String est_type		= StringUtil.nvl(request.getParameter("est_type"), "1");	//1:견적서, 2:예약확인서



	if (est_no.equals("")) {
		job_type = "C";
	}


	int air_amount			= 0;		//국제선
	double total_usd		= 0;
	double deposit_usd		= 0;
	double remain_usd		= 0;
	double deposit_currency	= 0;
	double remain_currency	= 0;

	String title			= "";		//제목


	HashMap infos = new HashMap();
	infos.put("est_no",	est_no);
	infos.put("req_id", req_id);


	SalesDAO dao 			= new SalesDAO();
	HashList estList 		= new HashList();
	HashList customerList	= new HashList();
	HashList airList		= new HashList();			//국제선
	HashList flyList		= new HashList();			//주내선
	HashList hotelList		= new HashList();			//호텔
	HashList enjoyList		= new HashList();			//선택관광
	HashList carList		= new HashList();			//렌터카
	HashList insureList		= new HashList();			//기타

	if ("".equals(est_no)) {		//신규등록
		if ("1".equals(est_type)) {
			title = "조인하와이 견적서";
			customerList = dao.selectReqInfo(infos);		//견적의뢰
			HashMap insureInfo = new HashMap();
			insureInfo.put("insure_name", "한화");
			insureInfo.put("insure_info", "여행자보험 1억 한도");
			insureList.add(insureInfo);
		} else if ("2".equals(est_type)) {
			title = "조인하와이 예약확인서";
		}
	} else {
		estList 		= dao.selectEstInfo(infos);				//견적서
		customerList	= dao.selectCustomerList(infos);
		airList			= dao.selectAirList(infos);				//국제선
		flyList			= dao.selectFlyList(infos);				//주내선
		hotelList		= dao.selectHotelList(infos);			//호텔
		enjoyList		= dao.selectEnjoyList(infos);			//선택관광
		carList			= dao.selectCarList(infos);				//렌터카
		insureList		= dao.selectInsureList(infos);				//기타

		title 				= estList.get("title",0);
		deposit_currency	= estList.getDouble("deposit_currency", 0);
		remain_currency		= estList.getDouble("remain_currency", 0);
	}

%>

<script>
<%	if (customerList.size() == 0) {	%>
		fnAddRow('customer');
		fnAddRow('customer');
<%	} else if (customerList.size() == 1) {	%>
		fnAddRow('customer');
<%	}	%>
<%	if (airList.size() == 0) {	%>
		fnAddRow('air');
<%	}	%>
<%	if (flyList.size() == 0) {	%>
		fnAddRow('fly');
<%	}	%>
<%	if (hotelList.size() == 0) {	%>
		fnAddRow('hotel');
<%	}	%>
<%	if (enjoyList.size() == 0) {	%>
		fnAddRow('enjoy');
<%	}	%>
<%	if (carList.size() == 0) {	%>
		fnAddRow('car');
<%	}	%>
<%	if (insureList.size() == 0) {	%>
		fnAddRow('insure');
<%	}	%>

	function fnAddRow(gubn) {
		if (gubn == 'customer') {
			var txt = '<tr>'
					+ '<td><input type="hidden" name="customer.init_user" value="" />'
					+ '<input type="text" name="customer.customer_name" value="" /></td>'
					+ '<td><input type="text" name="customer.customer_eng_name" value="" /></td>'
					+ '<td><select name="customer.sex" class="w50"><%= StringUtil.makeOption(code102, "") %></select></td>'
					+ '<td><input type="text" name="customer.res_no" value="" /></td>'
					+ '<td><input type="text" name="customer.tel_no" value="" /></td>'
					+ '<td><input type="text" name="customer.email_addr" value="" /></td>'
					+ '<td><input type="text" name="customer.remarks" value="" /></td>'
					+ '<td class="brx" onclick="fnDeleteRow(this)">삭제</td>'
					+ '</tr>';
			$("#customer").append(txt);
		}
		else if (gubn == 'air') {
			var txt = '<tr>'
					+ '<td><input type="hidden" name="air.init_user" value="" /><input type="hidden" name="air.dept_code" value="<%= session_dept_code %>" /><select name="air.air_code"><%= StringUtil.makeOption(code005, "") %></select></td>'
					+ '<td><input type="text" name="air.departure_time" value="" /></td>'
					+ '<td><input type="text" name="air.arrival_time" value="" /></td>'
					+ '<td><input type="text" name="air.price" value="" onchange="fnSetAirAmout(this)"/></td>'
					+ '<td><input type="text" name="air.person_count" value="" onchange="fnSetAirAmout(this)" /></td>'
					+ '<td><input type="text" name="air.amount" value="" /></td>'
					+ '<td class="brx c" onclick="fnDeleteRow(this)">삭제</td>'
					+ '</tr>';
			$("#air").append(txt);
		}
		else if (gubn == 'fly') {
			var txt = '<tr>'
					+ '<td><input type="hidden" name="fly.init_user" value="" />'
					+ '<input type="hidden" name="fly.est_state" value="1" />'
					+ '<input type="hidden" name="fly.issue_date" value="" />'
					+ '<input type="hidden" name="fly.issue_user" value="" />'
					+ '<input type="hidden" name="fly.dept_code" value="<%= session_dept_code %>" />'
					+ '<select name="fly.air_code"><%= StringUtil.makeOption(code005, "") %></select></td>'
					+ '<td><input type="text" name="fly.departure_time" value="" /></td>'
					+ '<td><input type="text" name="fly.transfer_time" value="" /></td>'
					+ '<td><input type="text" name="fly.arrival_time" value="" /></td>'
					+ '<td><input type="text" name="fly.price_usd" value="" onchange="fnSetFlyTotalUsd(this)" /></td>'
					+ '<td><input type="text" name="fly.person_count" value="" onchange="fnSetFlyTotalUsd(this)" /></td>'
					+ '<td><input type="text" name="fly.total_usd" value="" /></td>'
					+ '<td><input type="text" name="fly.deposit_usd" value=""  onchange="fnSetRemainUsd(this)"/></td>'
					+ '<td><input type="text" name="fly.remain_usd" value="" /></td>'
					+ '<td class="brx c" onclick="fnDeleteRow(this)">삭제</td>'
					+ '</tr>';
			$("#fly").append(txt);
		}
		else if (gubn == 'hotel') {
			var txt = '<tr>'
					+ '<td><input type="hidden" name="hotel.init_user" value="" />'
					+ '<input type="hidden" name="hotel.est_state" value="1" />'
					+ '<input type="hidden" name="hotel.issue_date" value="" />'
					+ '<input type="hidden" name="hotel.issue_user" value="" />'
					+ '<input type="hidden" name="hotel.dept_code" value="<%= session_dept_code %>" />'
					+ '<select name="hotel.land_code" class="w80"><%= StringUtil.makeOption(code001, "") %></select></td>'
					+ '<td><input type="text" name="hotel.start_dt" value=""/></td>'
					+ '<td><input type="text" name="hotel.end_dt" value=""/></td>'
					+ '<td><select name="hotel.hotel_id" class="w230"><%= StringUtil.makeOptionByGroup(codeHotel, "") %></select></td>'
					+ '<td><input type="text" name="hotel.add_person_count" value=""  onchange="fnSetHotelTotalUsd(this)"/></td>'
					+ '<td><input type="text" name="hotel.room_type" value="" /></td>'
					+ '<td><input type="text" name="hotel.bed_type" value=""/></td>'
					+ '<td><select name="hotel.bfst_yn" class="w80"><%= StringUtil.makeOption(code013, "") %></select></td>'
					+ '<td><select name="hotel.resort_yn" class="w80"><%= StringUtil.makeOption(code013, "") %></select></td>'
					+ '<td><input type="text" name="hotel.porterage_usd"  value="" onchange="fnSetHotelTotalUsd(this)"/></td>'
					+ '<td><input type="text" name="hotel.price_usd"  value="" onchange="fnSetHotelTotalUsd(this)"/></td>'
					+ '<td><input type="text" name="hotel.stay_day"  value="" onchange="fnSetHotelTotalUsd(this)"/></td>'
					+ '<td><input type="text" name="hotel.total_usd"  value=""/></td>'
					+ '<td><input type="text" name="hotel.deposit_usd"  value="" onchange="fnSetRemainUsd(this)"/></td>'
					+ '<td><input type="text" name="hotel.remain_usd"  value=""/></td>'
					+ '<td class="brx c"><a href="#nohref" onclick="fnDeleteRow(this)">삭제</a></td>'
					+ '</tr>';
			$("#hotel").append(txt);
		}
		else if (gubn == 'enjoy') {
			var txt = '<tr>'
				+ '<td><input type="hidden" name="enjoy.init_user" value="" />'
				+ '<input type="hidden" name="enjoy.est_state" value="1" />'
				+ '<input type="hidden" name="enjoy.issue_date" value="" />'
				+ '<input type="hidden" name="enjoy.issue_user" value="" />'
				+ '<input type="hidden" name="enjoy.dept_code" value="<%= session_dept_code %>" />'
				+ '<select name="enjoy.land_code" class="w80"><%= StringUtil.makeOption(code001, "") %></select></td>'
				+ '<td><input type="text" name="enjoy.start_dt" value=""/></td>'
				+ '<td><select name="enjoy.enjoy_id" class="w230"><%= StringUtil.makeOptionByGroup(codeEnjoy, "") %></select></td>'
				+ '<td><input type="text" name="enjoy.enjoy_cond" value="" /></td>'
				+ '<td><input type="text" name="enjoy.person_count"  value="" onchange="fnSetEnjoyTotalUsd(this)"/></td>'
				+ '<td><input type="text" name="enjoy.price_usd"  value="" onchange="fnSetEnjoyTotalUsd(this)"/></td>'
				+ '<td><input type="text" name="enjoy.total_usd"  value=""/></td>'
				+ '<td><input type="text" name="enjoy.deposit_usd"  value="" onchange="fnSetRemainUsd(this)"/></td>'
				+ '<td><input type="text" name="enjoy.remain_usd"  value=""/></td>'
				+ '<td class="brx c"><a href="#nohref" onclick="fnDeleteRow(this)">삭제</a></td>'
				+ '</tr>';
			$("#enjoy").append(txt);
		}
		else if (gubn == 'car') {
			var txt = '<tr>'
				+ '<td><input type="hidden" name="car.init_user" value="" />'
				+ '<input type="hidden" name="car.est_state" value="1" />'
				+ '<input type="hidden" name="car.issue_date" value="" />'
				+ '<input type="hidden" name="car.issue_user" value="" />'
				+ '<input type="hidden" name="car.dept_code" value="<%= session_dept_code %>" />'
				+ '<select name="car.land_code" class="w80"><%= StringUtil.makeOption(code001, "") %></select></td>'
				+ '<td><input type="text" name="car.start_dt" value=""/></td>'
				+ '<td><input type="text" name="car.end_dt" value=""/></td>'
				+ '<td><input type="text" name="car.rent_desc" value="풀보험<br/>제반비용<br/>TAX포함" /></td>'
				+ '<td><select name="car.car_company" class="w80"><%= StringUtil.makeOption(code106, "") %></select></td>'
				+ '<td><input type="text" name="car.pickup_name" value="" /></td>'
				+ '<td><select name="car.car_type" class="w100"><%= StringUtil.makeOption(code008, "") %></select></td>'

				+ '<td><input type="text" name="car.driver_name" value="" /></td>'
				+ '<td><select name="car.gps_code" class="w80"><%= StringUtil.makeOption(code013, "") %></select></td>'
				+ '<td><select name="car.return_code" class="w120"><%= StringUtil.makeOption(code110, "") %></select></td>'
				+ '<td><input type="text" name="car.rent_day" value=""  onchange="fnSetCarTotalUsd(this)"/></td>'
				+ '<td><input type="text" name="car.car_count"  value="" onchange="fnSetCarTotalUsd(this)"/></td>'

				+ '<td><input type="text" name="car.price_usd"  value="" onchange="fnSetCarTotalUsd(this)"/></td>'
				+ '<td><input type="text" name="car.total_usd"  value=""/></td>'
				+ '<td><input type="text" name="car.deposit_usd"  value="" onchange="fnSetRemainUsd(this)"/></td>'
				+ '<td><input type="text" name="car.remain_usd"  value=""/></td>'
				+ '<td class="brx c"><a href="#nohref" onclick="fnDeleteRow(this)">삭제</a></td>'
				+ '</tr>';
			$("#car").append(txt);
		}
		else if (gubn == 'insure') {
			var txt = '<tr>'
				+ '<td><input type="hidden" name="insure.init_user" value="" />'
				+ '<input type="hidden" name="insure.issue_user" value="" />'
				+ '<input type="hidden" name="insure.dept_code" value="<%= session_dept_code %>" />'
				+ '<input type="text" name="insure.insure_name" value="" /></td>'
				+ '<td><input type="text" name="insure.insure_info" value=""  class="l"/></td>'
				+ '<td><input type="text" name="insure.person_count"  value="" onchange="fnSetInsureTotalUsd(this)"/></td>'
				+ '<td><input type="text" name="insure.price_usd"  value="" onchange="fnSetInsureTotalUsd(this)"/></td>'
				+ '<td><input type="text" name="insure.total_usd"  value=""/></td>'
				+ '<td><input type="text" name="insure.deposit_usd"  value="" onchange="fnSetRemainUsd(this)"/></td>'
				+ '<td><input type="text" name="insure.remain_usd"  value=""/></td>'
				+ '<td class="brx c"><a href="#nohref" onclick="fnDeleteRow(this)">삭제</a></td>'
				+ '</tr>';
			$("#insure").append(txt);
		}
	}

	//국제선 총액 계산
	function fnSetAirAmout(oThis) {
		var amount = nvl($(oThis).closest('tr').find('input[name="air.price"]').val(),0)
					* nvl($(oThis).closest('tr').find('input[name="air.person_count"]').val(),0);
		$(oThis).closest('tr').find('input[name="air.amount"]').val(amount);
	}

	//주내선 총액 계산
	function fnSetFlyTotalUsd(oThis) {
		var total_usd = nvl($(oThis).closest('tr').find('input[name="fly.price_usd"]').val(),0)
						* nvl($(oThis).closest('tr').find('input[name="fly.person_count"]').val(),0);
		$(oThis).closest('tr').find('input[name="fly.total_usd"]').val(total_usd);
		fnSetRemainUsd(oThis);
	}

	//호텔 총액 계산
	function fnSetHotelTotalUsd(oThis) {
		var add_person_count = $(oThis).closest('tr').find('input[name="hotel.add_person_count"]').val();
		if (add_person_count == '' || add_person_count == '0') {
			add_person_count = '1';
		}
		var total_usd = parseFloat(nvl($(oThis).closest('tr').find('input[name="hotel.price_usd"]').val(),0))
						* parseFloat(nvl($(oThis).closest('tr').find('input[name="hotel.stay_day"]').val(),0))
						* parseFloat(add_person_count)
						+ parseFloat(nvl($(oThis).closest('tr').find('input[name="hotel.porterage_usd"]').val(),0));
		$(oThis).closest('tr').find('input[name="hotel.total_usd"]').val(total_usd);
		fnSetRemainUsd(oThis);
	}

	//선택관광 총액 계산
	function fnSetEnjoyTotalUsd(oThis) {
		var total_usd = nvl($(oThis).closest('tr').find('input[name="enjoy.price_usd"]').val(),0)
						* nvl($(oThis).closest('tr').find('input[name="enjoy.person_count"]').val(),0);
		$(oThis).closest('tr').find('input[name="enjoy.total_usd"]').val(total_usd);
		fnSetRemainUsd(oThis);
	}

	//렌터카 총액 계산
	function fnSetCarTotalUsd(oThis) {
		var total_usd = nvl($(oThis).closest('tr').find('input[name="car.rent_day"]').val(),0)
						* nvl($(oThis).closest('tr').find('input[name="car.car_count"]').val(),0)
						* nvl($(oThis).closest('tr').find('input[name="car.price_usd"]').val(),0);
		$(oThis).closest('tr').find('input[name="car.total_usd"]').val(total_usd);
		fnSetRemainUsd(oThis);
	}

	//보험 총액 계산
	function fnSetInsureTotalUsd(oThis) {
		var total_usd = nvl($(oThis).closest('tr').find('input[name="insure.price_usd"]').val(),0)
						* nvl($(oThis).closest('tr').find('input[name="insure.person_count"]').val(),0);
		$(oThis).closest('tr').find('input[name="insure.total_usd"]').val(total_usd);
		fnSetRemainUsd(oThis);
	}


	//잔금 계산
	function fnSetRemainUsd(oThis) {
		var remain_usd = nvl($(oThis).closest('tr').find('input[name$=".total_usd"]').val(),0)
				- nvl($(oThis).closest('tr').find('input[name$=".deposit_usd"]').val(),0);

		$(oThis).closest('tr').find('input[name$=".remain_usd"]').val(remain_usd);
	}

	//행삭제
	function fnDeleteRow(oThis) {
		$(oThis).closest('tr').remove();
	}
</script>

				<form name="estSaveForm" id="estSaveForm" method="post" action="">
				<input type="hidden" name="job_type" value="<%= job_type %>" />
				<input type="hidden" name="req_id" value="<%= req_id %>" />
				<input type="hidden" name="est_no" value="<%= estList.get("est_no",0) %>"/>
				<input type="hidden" name="est_state" value="<%= estList.get("est_state",0) %>"/>
				<input type="hidden" name="est_type" value="<%= est_type %>"/>



				<table cellpadding="0" cellspacing="0" class="table_04 mt5">
				<colgroup>
					<col width="50px"/>
					<col/>
				</colgroup>
				<tbody>
					<tr>
						<th class="bl2"></th>
						<td class="br2 p0">
							<table cellpadding="0" cellspacing="0" class="table_est">
							<colgroup>
								<col width="78px"/>
								<col width="101px"/>
								<col width="60px"/>
								<col width="92px"/>
								<col width="60px"/>
								<col width="100px"/>
								<col width="60px"/>
								<col width="110px"/>
								<col width="60px"/>
								<col/>
							</colgroup>
							<tbody>
								<tr height="30px">
									<td colspan="10" class="bt0 brx"><input type="text" name="title" class="est_title" value="<%= title %>"/></td>
								</tr>
								<tr>
									<th class="bt1"><p><b>번호</b></p></th>
									<td class="c"><%= estList.get("est_no",0) %></td>
									<th class="bt1"><p><b>발행일</b></p></th>
									<td class="c"><input type="text" name="issue_dt" id="issue_dt" value="<%= estList.get("issue_dt",0) %>" /></td>
									<th class="bt1"><p><b>작성자</b></p></th>
									<td class="c"><input type="text" name="issue_user" value="<%= StringUtil.nvl(estList.get("issue_user",0), session_user_name) %>" /></td>
									<th class="bt1"><p>구분</p></th>
									<td><input type="text" name="est_gubn" value="<%= estList.get("est_gubn",0) %>" /></td>
									<th class="bt1"><p>비고</p></th>
									<td class="brx"><input type="text" name="est_remarks" value="<%= estList.get("est_remarks",0) %>" /></td>
								</tr>
							</tbody>
							</table>
						</td>
					</tr>

					<tr>
						<th class="bl2" rowspan="2"><p><b>고<br/>객<br/>기<br/>본<br/>정<br/>보</b></p></th>
						<td class="p0 br2">
							<table cellpadding="0" cellspacing="0" class="table_est">
							<colgroup>
								<col width="80px"/>
								<col width="252px"/>
								<col width="30px"/>
								<col width="128px"/>
								<col width="128px"/>
								<col width="200px"/>
								<col/>
								<col width="40px"/>
							</colgroup>
							<tbody id="customer">
								<tr>
									<th><p>이름</p></th>
									<th><p>영문</p></th>
									<th><p>성별</p></th>
									<th><p>생년월일</p></th>
									<th><p>연락처</p></th>
									<th><p>이메일</p></th>
									<th><p>비고</p></th>
									<th class="brx"><a href="#nohref" onclick="fnAddRow('customer')"><p>추가</p></a></th>
								</tr>


							<%	for (int i = 0; i < customerList.size(); i++) { %>
								<tr>
									<td>
										<input type="hidden" name="customer.init_user" value="<%= customerList.get("init_user", i) %>" />
										<input type="text" name="customer.customer_name" value="<%= customerList.get("customer_name", i) %>" />
									</td>
									<td><input type="text" name="customer.customer_eng_name" value="<%= StringUtil.nvl(customerList.get("customer_eng_name", i)) %>" /></td>
									<td><select name="customer.sex" class="w50"><%= StringUtil.makeOption(code102, customerList.get("sex", i)) %></select></td>
									<td><input type="text" name="customer.res_no" value="<%= StringUtil.nvl(customerList.get("res_no", i)) %>" /></td>
									<td><input type="text" name="customer.tel_no" value="<%= StringUtil.nvl(customerList.get("tel_no", i)) %>" /></td>
									<td><input type="text" name="customer.email_addr" value="<%= StringUtil.nvl(customerList.get("email_addr", i)) %>" /></td>
									<td><input type="text" name="customer.remarks" value="<%= StringUtil.nvl(customerList.get("remarks", i)) %>" /></td>
									<td class="brx"><a href="#nohref" onclick="fnDeleteRow(this)">삭제</a></td>
								</tr>
							<%	} %>
							</tbody>
							</table>
						</td>
					</tr>


					<tr>
						<td class="p0">
							<table cellpadding="0" cellspacing="0" class="table_est">
							<colgroup>
								<col width="80px"/>
								<col width="175px"/>
								<col width="120px"/>
								<col width="80px"/>
								<col width="98px"/>
								<col width="97px"/>
								<col/>
							</colgroup>
							<tbody>
								<tr >
									<th class="bb1"><p><b>여행종류</b></p></th>
									<td class="bt0">
										<select name="travel_gubn" class="w80"><%= StringUtil.makeOption(code100, estList.get("travel_gubn",0)) %></select>
										<select name="travel_type" class="w80"><%= StringUtil.makeOption(code101, estList.get("travel_type",0)) %></select>
									</td>
									<td class="bt0"><input type="text" name="travel_desc" value="<%= estList.get("travel_desc",0)%>"/></td>
									<th><p><b>여행일정</b></p></th>
									<td class="bt0"><input type="text" name="travel_start_dt" id="travel_start_dt" value="<%= estList.get("travel_start_dt",0)%>"/></td>
									<td class="bt0"><input type="text" name="travel_end_dt" id="travel_end_dt" value="<%= estList.get("travel_end_dt",0)%>" /></td>
									<td class="bt0"><input type="text" name="island" class="l" value="<%= StringUtil.nvl(estList.get("island",0),"(0박 0일)") %>" /></td>
								</tr>
								<tr>
									<th><p><b>비고</b></p></th>
									<td colspan="6"><input type="text" name="remarks" value="<%= estList.get("remarks",0)%>" /></td>
								</tr>
							</tbody>
							</table>
						</td>
					</tr>

					<tr>
						<th class="bl2 bt2"><p><b>국제선</b></p></th>
						<td class="br2 bt2 p0">
							<table cellpadding="0" cellspacing="0" class="table_est">
							<colgroup>
								<col width="80px"/>
								<col width="252px"/>
								<col />
								<col width="60px"/>
								<col width="60px"/>
								<col width="182px"/>
								<col width="40px"/>
							</colgroup>
							<tbody id="air">
								<tr>
									<th><p>항공사</p></th>
									<th><p>호노룰루도착</p></th>
									<th><p>호노룰루출발</p></th>
									<th><p>1인요금</p></th>
									<th><p>인원수</p></th>
									<th><p>총액</p></th>
									<th class="brx"><p><a href="#nohref" onclick="fnAddRow('air')">추가</a></p></th>
								</tr>
							<%	for (int i = 0; i < airList.size(); i++) {
									air_amount += airList.getInt("amount",i);
							%>
								<tr>
									<td>
										<input type="hidden" name="air.init_user" value="<%= airList.get("init_user", i) %>" />
										<input type="hidden" name="air.dept_code" value="<%= airList.get("dept_code", i) %>" />
										<select name="air.air_code"><%= StringUtil.makeOption(code005, airList.get("air_code",i)) %></select>
									</td>
									<td><input type="text" name="air.departure_time" value="<%= airList.get("departure_time",i) %>" /></td>
									<td><input type="text" name="air.arrival_time" value="<%= airList.get("arrival_time",i) %>" /></td>
									<td><input type="text" name="air.price" value="<%= airList.get("price",i) %>"  onchange="fnSetAirAmout(this)"/></td>
									<td><input type="text" name="air.person_count" value="<%= airList.get("person_count",i) %>"  onchange="fnSetAirAmout(this)"/></td>
									<td><input type="text" name="air.amount" value="<%= airList.get("amount",i) %>" /></td>
									<td class="brx c"><a href="#nohref" onclick="fnDeleteRow(this)">삭제</a></td>
								</tr>
							<%	} %>
							</tbody>
							<tfooter>
								<tr>
									<th class="bt1"><p>비고</p></th>
									<td colspan="6" class="brx c"><input type="text" name="air_remarks" value="<%= estList.get("air_remarks",0) %>"/></td>
								</tr>
							</tfooter>
							</table>
						</td>
					</tr>

					<tr>
						<th class="bl2 bt2"><p><b>주내선</b></p></th>
						<td class="br2 bt2 p0">
							<table cellpadding="0" cellspacing="0" class="table_est">
							<colgroup>
								<col width="80px"/>
								<col width="180px"/>
								<col width="180px"/>
								<col />
								<col width="60px"/>
								<col width="60px"/>
								<col width="60px"/>
								<col width="60px"/>
								<col width="60px"/>
								<col width="40px"/>
							</colgroup>
							<tbody id="fly">
								<tr>
									<th><p>항공사</p></th>
									<th><p>출발</p></th>
									<th><p>경유</p></th>
									<th><p>귀환</p></th>
									<th><p>1인요금</p></th>
									<th><p>인원수</p></th>
									<th><p>총액</p></th>
									<th><p>예약금</p></th>
									<th><p>잔금</p></th>
									<th class="brx"><p><a href="#nohref" onclick="fnAddRow('fly')">추가</a></p></th>
								</tr>
							<%	for (int i = 0; i < flyList.size(); i++) {
									total_usd 	+= flyList.getDouble("total_usd",i);
									deposit_usd += flyList.getDouble("deposit_usd",i);
									remain_usd	+= flyList.getDouble("remain_usd",i);
							%>
								<tr>
									<td>
										<input type="hidden" name="fly.init_user" value="<%= flyList.get("init_user", i) %>" />
										<input type="hidden" name="fly.dept_code" value="<%= flyList.get("dept_code", i) %>" />
										<input type="hidden" name="fly.est_state" value="<%= flyList.get("est_state", i) %>" />
										<input type="hidden" name="fly.issue_date" value="<%= flyList.get("issue_date", i) %>" />
										<input type="hidden" name="fly.issue_user" value="<%= flyList.get("issue_user", i) %>" />
										<select name="fly.air_code"><%= StringUtil.makeOption(code005, flyList.get("air_code",i)) %></select>
									</td>
									<td><input type="text" name="fly.departure_time" value="<%= flyList.get("departure_time",i) %>" /></td>
									<td><input type="text" name="fly.transfer_time" value="<%= flyList.get("transfer_time",i) %>" /></td>
									<td><input type="text" name="fly.arrival_time" value="<%= flyList.get("arrival_time",i) %>" /></td>
									<td><input type="text" name="fly.price_usd" value="<%= flyList.get("price_usd",i) %>"  onchange="fnSetFlyTotalUsd(this)"/></td>
									<td><input type="text" name="fly.person_count" value="<%= flyList.get("person_count",i) %>"  onchange="fnSetFlyTotalUsd(this)"/></td>
									<td><input type="text" name="fly.total_usd" value="<%= flyList.get("total_usd",i) %>" /></td>
									<td><input type="text" name="fly.deposit_usd" value="<%= flyList.get("deposit_usd",i) %>"  onchange="fnSetRemainUsd(this)"/></td>
									<td><input type="text" name="fly.remain_usd" value="<%= flyList.get("remain_usd",i) %>" /></td>
									<td class="brx c"><a href="#nohref" onclick="fnDeleteRow(this)">삭제</a></td>
								</tr>
							<%	} %>
							</tbody>
							<tfooter>
								<tr>
									<th class="bt1"><p>비고</p></th>
									<td colspan="9" class="brx c"><input type="text" name="fly_remarks" value="<%= estList.get("fly_remarks",0) %>"/></td>
								</tr>
							</tfooter>
							</table>
						</td>
					</tr>

					<tr>
						<th class="bl2 bt2"><p><b>호텔</b></p></th>
						<td class="br2 bt2 p0">
							<table cellpadding="0" cellspacing="0" class="table_est">
							<colgroup>
								<col width="45px"/>
								<col width="50px"/>
								<col width="50px"/>
								<col />
								<col width="42px"/>
								<col width="42px"/>
								<col width="42px"/>
								<col width="42px"/>
								<col width="46px"/>
								<col width="46px"/>

								<col width="60px"/>
								<col width="60px"/>
								<col width="60px"/>
								<col width="60px"/>
								<col width="60px"/>
								<col width="40px"/>
							</colgroup>
							<tbody id="hotel">
								<tr>

									<th><p>장소</p></th>
									<th colspan="2"><p>날짜</p></th>
									<th><p>호텔</p></th>
									<th><p>추인</p></th>
									<th><p>객실</p></th>
									<th><p>침대</p></th>
									<th><p>조식</p></th>
									<th><p>리조트</p></th>
									<th><p>Port</p></th>
									<th><p>1박요금</p></th>
									<th><p>숙박일</p></th>
									<th><p>총액</p></th>
									<th><p>예약금</p></th>
									<th><p>잔금</p></th>
									<th class="brx"><p><a href="#nohref" onclick="fnAddRow('hotel')">추가</a></p></th>
								</tr>
							<%	for (int i = 0; i < hotelList.size(); i++) {
								total_usd 	+= hotelList.getDouble("total_usd",i);
								deposit_usd += hotelList.getDouble("deposit_usd",i);
								remain_usd	+= hotelList.getDouble("remain_usd",i);
							%>
								<tr>
									<td>
										<input type="hidden" name="hotel.init_user" value="<%= hotelList.get("init_user", i) %>" />
										<input type="hidden" name="hotel.dept_code" value="<%= hotelList.get("dept_code", i) %>" />
										<input type="hidden" name="hotel.est_state" value="<%= hotelList.get("est_state", i) %>" />
										<input type="hidden" name="hotel.issue_date" value="<%= hotelList.get("issue_date", i) %>" />
										<input type="hidden" name="hotel.issue_user" value="<%= hotelList.get("issue_user", i) %>" />
										<select name="hotel.land_code" class="w80"><%= StringUtil.makeOption(code001, hotelList.get("land_code", i)) %></select>
									</td>
									<td><input type="text" name="hotel.start_dt" value="<%=hotelList.get("start_dt", i)%>"/></td>
									<td><input type="text" name="hotel.end_dt" value="<%=hotelList.get("end_dt", i)%>"/></td>
									<td><select name="hotel.hotel_id" class="w230"><%= StringUtil.makeOptionByGroup(codeHotel, hotelList.get("hotel_id", i)) %></select></td>
									<td><input type="text" name="hotel.add_person_count" value="<%=hotelList.get("add_person_count", i)%>"  onchange="fnSetHotelTotalUsd(this)"/></td>
									<td><input type="text" name="hotel.room_type" value="<%=hotelList.get("room_type", i)%>" /></td>
									<td><input type="text" name="hotel.bed_type" value="<%=hotelList.get("bed_type", i)%>"/></td>
									<td><select name="hotel.bfst_yn" class="w80"><%= StringUtil.makeOption(code013, hotelList.get("bfst_yn", i)) %></select></td>
									<td><select name="hotel.resort_yn" class="w80"><%= StringUtil.makeOption(code013, hotelList.get("resort_yn", i)) %></select></td>
									<td><input type="text" name="hotel.porterage_usd"  value="<%=hotelList.get("porterage_usd", i)%>" onchange="fnSetHotelTotalUsd(this)"/></td>
									<td><input type="text" name="hotel.price_usd"  value="<%=hotelList.get("price_usd", i)%>" onchange="fnSetHotelTotalUsd(this)"/></td>
									<td><input type="text" name="hotel.stay_day"  value="<%=hotelList.get("stay_day", i)%>" onchange="fnSetHotelTotalUsd(this)"/></td>
									<td><input type="text" name="hotel.total_usd"  value="<%=hotelList.get("total_usd", i)%>"/></td>
									<td><input type="text" name="hotel.deposit_usd"  value="<%=hotelList.get("deposit_usd", i)%>" onchange="fnSetRemainUsd(this)"/></td>
									<td><input type="text" name="hotel.remain_usd"  value="<%=hotelList.get("remain_usd", i)%>"/></td>
									<td class="brx c"><a href="#nohref" onclick="fnDeleteRow(this)">삭제</a></td>
								</tr>
							<%	} %>
							</tbody>
							<tfooter>
								<tr>
									<th class="bt1"><p>비고</p></th>
									<td colspan="15" class="brx c"><input type="text" name="hotel_remarks" value="<%= estList.get("hotel_remarks",0) %>"/></td>
								</tr>
							</tfooter>
							</table>
						</td>
					</tr>

					<tr>
						<th class="bl2 bt2"><p><b>선택<br/>관광</b></p></th>
						<td class="br2 bt2 p0">
							<table cellpadding="0" cellspacing="0" class="table_est">
							<colgroup>
								<col width="45px"/>
								<col width="100px"/>
								<col width="231px"/>
								<col/>
								<col width="60px"/>
								<col width="60px"/>
								<col width="60px"/>
								<col width="60px"/>
								<col width="60px"/>
								<col width="40px"/>
							</colgroup>
							<tbody id="enjoy">
								<tr>
									<th><p>장소</p></th>
									<th><p>날짜</p></th>
									<th><p>상품</p></th>
									<th><p>조건</p></th>
									<th><p>인원수</p></th>
									<th><p>1인요금</p></th>
									<th><p>총액</p></th>
									<th><p>예약금</p></th>
									<th><p>잔금</p></th>
									<th class="brx"><p><a href="#nohref" onclick="fnAddRow('enjoy')">추가</a></p></th>
								</tr>
							<%	for (int i = 0; i < enjoyList.size(); i++) {
									total_usd 	+= enjoyList.getDouble("total_usd",i);
									deposit_usd += enjoyList.getDouble("deposit_usd",i);
									remain_usd	+= enjoyList.getDouble("remain_usd",i);
							%>
								<tr>
									<td>
										<input type="hidden" name="enjoy.init_user" value="<%= enjoyList.get("init_user", i) %>" />
										<input type="hidden" name="enjoy.dept_code" value="<%= enjoyList.get("dept_code", i) %>" />
										<input type="hidden" name="enjoy.est_state" value="<%= enjoyList.get("est_state", i) %>" />
										<input type="hidden" name="enjoy.issue_date" value="<%= enjoyList.get("issue_date", i) %>" />
										<input type="hidden" name="enjoy.issue_user" value="<%= enjoyList.get("issue_user", i) %>" />
										<select name="enjoy.land_code" class="w80"><%= StringUtil.makeOption(code001, enjoyList.get("land_code", i)) %></select>
									</td>
									<td><input type="text" name="enjoy.start_dt" value="<%=enjoyList.get("start_dt", i)%>"/></td>
									<td><select name="enjoy.enjoy_id" class="w230"><%= StringUtil.makeOptionByGroup(codeEnjoy, enjoyList.get("enjoy_id", i)) %></select></td>
									<td><input type="text" name="enjoy.enjoy_cond" value="<%=enjoyList.get("enjoy_cond", i)%>" /></td>
									<td><input type="text" name="enjoy.person_count"  value="<%=enjoyList.get("person_count", i)%>" onchange="fnSetEnjoyTotalUsd(this)"/></td>
									<td><input type="text" name="enjoy.price_usd"  value="<%=enjoyList.get("price_usd", i)%>" onchange="fnSetEnjoyTotalUsd(this)"/></td>
									<td><input type="text" name="enjoy.total_usd"  value="<%=enjoyList.get("total_usd", i)%>"/></td>
									<td><input type="text" name="enjoy.deposit_usd"  value="<%=enjoyList.get("deposit_usd", i)%>" onchange="fnSetRemainUsd(this)"/></td>
									<td><input type="text" name="enjoy.remain_usd"  value="<%=enjoyList.get("remain_usd", i)%>"/></td>
									<td class="brx c"><a href="#nohref" onclick="fnDeleteRow(this)">삭제</a></td>
								</tr>
							<%	} %>
							</tbody>
							<tfooter>
								<tr>
									<th class="bt1"><p>비고</p></th>
									<td colspan="9" class="brx c"><input type="text" name="enjoy_remarks" value="<%= estList.get("enjoy_remarks",0) %>"/></td>
								</tr>
							</tfooter>
							</table>
						</td>
					</tr>

					<tr>
						<th class="bl2 bt2"><p><b>렌터카</b></p></th>
						<td class="br2 bt2 p0">
							<table cellpadding="0" cellspacing="0" class="table_est">
							<colgroup>
								<col width="45px"/>
								<col width="50px"/>
								<col width="50px"/>
								<col/>
								<col width="40px"/>
								<col width="40px"/>
								<col width="75px"/>

								<col width="60px"/>
								<col width="50px"/>
								<col width="89px"/>
								<col width="30px"/>
								<col width="29px"/>

								<col width="60px"/>
								<col width="60px"/>
								<col width="60px"/>
								<col width="60px"/>
								<col width="40px"/>
							</colgroup>
							<tbody id="car">
								<tr>
									<th><p>장소</p></th>
									<th colspan="2"><p>날짜</p></th>
									<th><p>조건</p></th>
									<th><p>회사</p></th>
									<th><p>픽업</p></th>
									<th><p>차종</p></th>

									<th><p>운전자</p></th>
									<th><p>GPS</p></th>
									<th><p>픽업/반납</p></th>
									<th><p>일수</p></th>
									<th><p>대수</p></th>

									<th><p>1일요금</p></th>
									<th><p>총액</p></th>
									<th><p>예약금</p></th>
									<th><p>잔금</p></th>
									<th class="brx"><p><a href="#nohref" onclick="fnAddRow('car')">추가</a></p></th>
								</tr>
							<%	for (int i = 0; i < carList.size(); i++) {
									total_usd 	+= carList.getDouble("total_usd",i);
									deposit_usd += carList.getDouble("deposit_usd",i);
									remain_usd	+= carList.getDouble("remain_usd",i);
							%>
								<tr>
									<td>
										<input type="hidden" name="car.init_user" value="<%= carList.get("init_user", i) %>" />
										<input type="hidden" name="car.dept_code" value="<%= carList.get("dept_code", i) %>" />
										<input type="hidden" name="car.est_state" value="<%= carList.get("est_state", i) %>" />
										<input type="hidden" name="car.issue_date" value="<%= carList.get("issue_date", i) %>" />
										<input type="hidden" name="car.issue_user" value="<%= carList.get("issue_user", i) %>" />
										<select name="car.land_code" class="w80"><%= StringUtil.makeOption(code001, carList.get("land_code", i)) %></select>
									</td>
									<td><input type="text" name="car.start_dt" value="<%=carList.get("start_dt", i)%>"/></td>
									<td><input type="text" name="car.end_dt" value="<%=carList.get("end_dt", i)%>"/></td>
									<td><input type="text" name="car.rent_desc" value="<%=carList.get("rent_desc", i)%>" /></td>
									<td><select name="car.car_company" class="w80"><%= StringUtil.makeOption(code106, carList.get("car_company", i)) %></select></td>
									<td><input type="text" name="car.pickup_name" value="<%=carList.get("pickup_name", i)%>" /></td>
									<td><select name="car.car_type" class="w100"><%= StringUtil.makeOption(code008, carList.get("car_type", i)) %></select></td>

									<td><input type="text" name="car.driver_name" value="<%=carList.get("driver_name", i)%>" /></td>
									<td><select name="car.gps_code" class="w80"><%= StringUtil.makeOption(code013, carList.get("gps_code", i)) %></select></td>
									<td><select name="car.return_code" class="w120"><%= StringUtil.makeOption(code110, carList.get("return_code", i)) %></select></td>
									<td><input type="text" name="car.rent_day" value="<%=carList.get("rent_day", i)%>"  onchange="fnSetCarTotalUsd(this)"/></td>
									<td><input type="text" name="car.car_count"  value="<%=carList.get("car_count", i)%>" onchange="fnSetCarTotalUsd(this)"/></td>

									<td><input type="text" name="car.price_usd"  value="<%=carList.get("price_usd", i)%>" onchange="fnSetCarTotalUsd(this)"/></td>
									<td><input type="text" name="car.total_usd"  value="<%=carList.get("total_usd", i)%>"/></td>
									<td><input type="text" name="car.deposit_usd"  value="<%=carList.get("deposit_usd", i)%>" onchange="fnSetRemainUsd(this)"/></td>
									<td><input type="text" name="car.remain_usd"  value="<%=carList.get("remain_usd", i)%>"/></td>
									<td class="brx c"><a href="#nohref" onclick="fnDeleteRow(this)">삭제</a></td>
								</tr>
							<%	} %>
							</tbody>
							<tfooter>
								<tr>
									<th class="bt1"><p>비고</p></th>
									<td colspan="16" class="brx c"><input type="text" name="car_remarks" value="<%= estList.get("car_remarks",0) %>"/></td>
								</tr>
							</tfooter>
							</table>
						</td>
					</tr>

					<tr>
						<th class="bl2 bt2"><p><b>보험</b></p></th>
						<td class="br2 bt2 p0">
							<table cellpadding="0" cellspacing="0" class="table_est">
							<colgroup>
								<col width="45px"/>
								<col/>
								<col width="60px"/>
								<col width="60px"/>
								<col width="60px"/>
								<col width="60px"/>
								<col width="60px"/>
								<col width="40px"/>
							</colgroup>
							<tbody id="insure">
								<tr>
									<th><p>항목</p></th>
									<th><p>내용</p></th>
									<th><p>인원수</p></th>
									<th><p>1인요금</p></th>
									<th><p>총액</p></th>
									<th><p>예약금</p></th>
									<th><p>잔금</p></th>
									<th class="brx"><a href="#nohref" onclick="fnAddRow('insure')"><p>추가</p></a></th>
								</tr>
							<%	for (int i = 0; i < insureList.size(); i++) {
									total_usd 	+= insureList.getDouble("total_usd",i);
									deposit_usd += insureList.getDouble("deposit_usd",i);
									remain_usd	+= insureList.getDouble("remain_usd",i);
							%>
								<tr>
									<td>
										<input type="hidden" name="insure.init_user" value="<%= insureList.get("init_user", i) %>" />
										<input type="hidden" name="insure.issue_user" value="<%= insureList.get("issue_user", i) %>" />
										<input type="hidden" name="insure.dept_code" value="<%= insureList.get("dept_code", i) %>" />
										<input type="text" name="insure.insure_name" value="<%=insureList.get("insure_name", i)%>" />
									</td>
									<td><input type="text" name="insure.insure_info" value="<%=insureList.get("insure_info", i)%>"  class="l"/></td>
									<td><input type="text" name="insure.person_count"  value="<%=StringUtil.nvl(insureList.get("person_count", i))%>" onchange="fnSetInsureTotalUsd(this)"/></td>
									<td><input type="text" name="insure.price_usd"  value="<%=StringUtil.nvl(insureList.get("price_usd", i))%>" onchange="fnSetInsureTotalUsd(this)"/></td>
									<td><input type="text" name="insure.total_usd"  value="<%=StringUtil.nvl(insureList.get("total_usd", i))%>"/></td>
									<td><input type="text" name="insure.deposit_usd"  value="<%=StringUtil.nvl(insureList.get("deposit_usd", i))%>" onchange="fnSetRemainUsd(this)"/></td>
									<td><input type="text" name="insure.remain_usd"  value="<%=StringUtil.nvl(insureList.get("remain_usd", i))%>"/></td>
									<td class="brx c"><a href="#nohref" onclick="fnDeleteRow(this)">삭제</a></td>
								</tr>
							<%	} %>
							</tbody>
							<tfooter>
								<tr>
									<th class="bt1"><p>비고</p></th>
									<td colspan="7" class="brx c"><input type="text" name="insure_remarks" value="<%= estList.get("insure_remarks",0) %>"/></td>
								</tr>
							</tfooter>
							</table>
						</td>
					</tr>


					<tr>
						<th class="bl2 bt2"><p><b>결<br/>재<br/>사<br/>항</p></th>
						<td class="br2 bt2 bb2 p0">
							<table cellpadding="0" cellspacing="0" class="table_est">
							<colgroup>
								<col/>
								<col/>
								<col width="60px"/>
								<col width="60px"/>
								<col width="60px"/>
								<col width="60px"/>
								<col width="40px"/>
							</colgroup>
							<tbody id="enjoy">
								<tr>
									<th><p>총내역</p></th>
									<th><p>예약금내역</p></th>
									<th><p></p></th>
									<th><p>총액</p></th>
									<th><p>예약금</p></th>
									<th><p>잔금</p></th>
									<th class="brx"><p></p></th>
								</tr>
								<tr>
									<td rowspan="5"><textarea name="total_desc"><%= estList.get("total_desc",0) %></textarea></td>
									<td rowspan="5"><textarea name="deposit_desc"><%= estList.get("deposit_desc",0) %></textarea></td>
									<th><p>국제선</p></th>
									<td><%= StringUtil.toPrice(air_amount) %></td>
									<td></td>
									<td></td>
									<td class="brx"></td>
								</tr>
								<tr>
									<th><p>미화</p></th>
									<td>$<%= total_usd %></td>
									<td>$<%= deposit_usd %></td>
									<td>$<%= remain_usd %></td>
									<td class="brx"></td>
								</tr>
								<tr>
									<th><p>원화</p></th>
									<td><%= StringUtil.toPrice((long)(air_amount + deposit_usd * deposit_currency + remain_usd * remain_currency)) %></td>
									<td><%= StringUtil.toPrice((long)(deposit_usd * deposit_currency)) %></td>
									<td><%= StringUtil.toPrice((long)(remain_usd * remain_currency)) %></td>
									<td class="brx"></td>
								</tr>
								<tr>
									<th><p>환율</p></th>
									<td></td>
									<td><input type="text" name="deposit_currency"  value="<%= estList.get("deposit_currency",0) %>"/></td>
									<td><input type="text" name="remain_currency"  value="<%= estList.get("remain_currency",0) %>"/></td>
									<td class="brx"></td>
								</tr>
								<tr>
									<th><p>카드</p></th>
									<td></td>
									<td><input type="checkbox" name="deposit_card_yn" value="Y" <%= StringUtil.checked("Y",estList.get("deposit_card_yn",0)) %>/></td>
									<td><input type="checkbox" name="remain_card_yn" value="Y" <%= StringUtil.checked("Y",estList.get("remain_card_yn",0)) %>/></td>
									<td class="brx"></td>
								</tr>
							</tbody>
							</table>
						</td>
					</tr>

				</tbody>
				</table>

				<div class="mt20 mb10 c">
			<%	if ("U".equals(job_type)) { %>
					<a href="#nohref" onclick="fnEstSave('U')"><img src="/images/admin/btn_update.gif" /></a>
				<%	if ("1".equals(est_type)) { %>
						<a href="#nohref" onclick="fnEstSave('C')"><img src="/images/admin/btn_saveas.gif" /></a>
						<a href="#nohref" onclick="fnReserve()"><img src="/images/admin/btn_reserve.gif" /></a>
				<%	} %>
					<a href="#nohref" onclick="fnEstPrint('<%=est_no%>')"><img src="/images/admin/btn_print.gif" /></a>
					<a href="#nohref" onclick="fnEstSave('D')"><img src="/images/admin/btn_delete.gif" /></a>
			<%	} else if ("C".equals(job_type)) { %>
					<a href="#nohref" onclick="fnEstSave('C')"><img src="/images/admin/btn_register.gif" /></a>
			<%	} %>
				</div>

				</form>
